﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NutriLeaf.Web.Core.Meals
{
    public class MealDairy:Meals.IMealDiary
    {
        public void EatMeal(int userId, int mealId, DateTime clientDateTime, ref Model.NutriLeafDBEntities context)
        {
            Model.MealDiary dairy = new Model.MealDiary();
            dairy.UserID = userId;
            dairy.MealID = mealId;
            dairy.ClientDateTimeStamp = clientDateTime;
            dairy.DateTimeStamp = DateTime.Now;
            context.MealDiaries.AddObject(dairy);
            context.SaveChanges();
        }

        public void RemoveMealDiaryEntry(int mealDiaryId, ref Model.NutriLeafDBEntities context)
        {
            context.DeleteObject(context.MealDiaries.Where(p=>p.MealID==mealDiaryId).First());
            context.SaveChanges();

        }
    }
}